local SkillBase = require("gameLogic.fightSkill.show.SkillBase")
local SkillConfusion = class("SkillConfusion", SkillBase)
local FightConst = require("const.FightConst")
-- 混乱技能（装饰者）

function SkillConfusion:ctor(child)
    SkillConfusion.super.ctor(self)
    self._child = child
    self:setEntity(self._child:getEntity())
    self:setId(self._child:getId())
end

function SkillConfusion:attack()
    local oldStanding = self._child:getStanding()
    local randomStanding = math.random(FightConst.FRIEND_STANDING, FightConst.ENEMY_STANDING)
    self._child:setStanding(randomStanding)
    local manager = self:getEntity():getManager()
    local entitys = manager:getEnemyEntitys(self._child:getSkillTargetStanding())
    local index = math.random(1, #entitys)
    self._child:attack(index)
    self._child:setStanding(oldStanding)
end

return SkillConfusion
